跳到主要内容

maybe_deliver

API 概述

maybe_deliverLinux kernel 中的一个API。该规属于return value check 类型。该规则是使用 APISpecGen 生成的。

规则描述

提示

maybe_deliver returns error pointer on failure, use IS_ERR to check the return value

信息

标签:return value check

参数下标:N/A

CWE类别:CWE-253

规则代码


import cpp
import semmle.code.cpp.controlflow.SSA


class EVPFunctionCall extends FunctionCall {
EVPFunctionCall() {
this.getTarget().hasName("maybe_deliver")
}
}


predicate isErrCheckFunction(Function f) {
f.hasName("IS_ERR")
}

from EVPFunctionCall call, ValueAccess ret
where
ret = call.getAnAccess() and
not exists(FunctionCall check |
isErrCheckFunction(check.getTarget()) and
check.getArgument(0).getAChild*() = ret
)
select call, "The return value of maybe_deliver is not checked with IS_ERR."